package cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern;

import cn.edu.scau.cmi.yangzhengkai.singleton.Chairman;
import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class SingletonClient extends Application{
    @Override 
	public void start(Stage primaryStage) {
		
		FlowPane fp = new FlowPane();
		HBox hb = new HBox();
		TextField tfMessage = new TextField();
		fp.getChildren().add(hb);
		Button bu = new Button("创建主席");
		hb.getChildren().addAll(tfMessage,bu);
		fp.setOrientation(Orientation.VERTICAL);
		bu.setOnAction(MouseEvent ->{
			Chairman chairman = Chairman.getChairman(tfMessage.getText());
			Label lb = new Label();
			String str = chairman.getName() + chairman.toString();
			    lb = new Label(str);
			fp.getChildren().add(lb);
		});
		
		
		Scene scene = new Scene(fp);
		primaryStage.setScene(scene);
		primaryStage.setHeight(500);
		primaryStage.setWidth(500);
		primaryStage.show();
		
	}
    
    public static void main(String args[]) {
    	Application.launch(args);
    }

	

}
